package org.checkboo.hopefullyengine.light;

import java.nio.FloatBuffer;

import org.checkboo.hopefullyengine.sceneelements.Color;
import org.lwjgl.BufferUtils;

public class Light {

	private Color diffuse;
	private Color specular;
	private Color ambient;
	private FloatBuffer dis;
	private FloatBuffer spec;
	private FloatBuffer amb;
	
	public Light(){
		this.diffuse = new Color(1.0f, 1.0f, 1.0f, 1.0f);
		this.specular = new Color(1.0f, 1.0f, 1.0f, 1.0f);
		this.ambient = new Color(1.0f, 1.0f, 1.0f, 1.0f);
	}
	
	public Light(Color diffuse, Color specular, Color ambient){
		this.diffuse = diffuse;
		this.specular = specular;
		this.ambient = ambient;
	}

	public Color getDiffuse() {
		return diffuse;
	}
	
	public FloatBuffer getDiffuseBuffer(){
		if(null == dis)
			dis = BufferUtils.createFloatBuffer(4);
		dis.put(this.diffuse.getRed()).put(this.diffuse.getGreen()).put(this.diffuse.getBlue()).put(this.diffuse.getAlpha()).rewind();
		return dis;
	}

	public void setDiffuse(Color diffuse) {
		this.diffuse = diffuse;
	}

	public Color getSpecular() {
		return specular;
	}
	
	public FloatBuffer getSpecularBuffer(){
		if(null == spec)
			spec = BufferUtils.createFloatBuffer(4);
		spec.put(this.specular.getRed()).put(this.specular.getGreen()).put(this.specular.getBlue()).put(this.specular.getAlpha()).rewind();
		return spec;
	}

	public void setSpecular(Color specular) {
		this.specular = specular;
	}

	public Color getAmbient() {
		return ambient;
	}
	
	public FloatBuffer getAmbientBuffer(){
		if(null == amb)
			amb = BufferUtils.createFloatBuffer(4);
		amb.put(this.ambient.getRed()).put(this.ambient.getGreen()).put(this.ambient.getBlue()).put(this.ambient.getAlpha()).rewind();
		return amb;
	}

	public void setAmbient(Color ambient) {
		this.ambient = ambient;
	}
	
}
